/**
 * 
 */
package com.mc.jiSuan;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;

/**
 * 计算百分比
 * 
 * @author w.weizhen
 *
 */
public class BaiFenBi {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		for (int i = 0; i < 100; i++) 
		{
			double x = Math.random();
			int y = (int)(x*100);
			int z = (int)(x*100) + 1;
			
//			NumberFormat percentInstance = NumberFormat.getPercentInstance();
//	        // 设置保留几位小数，这里设置的是保留两位小数
//	        percentInstance.setMinimumFractionDigits(2);
	        //System.out.println(y + "/" + z + "=" + percentInstance.format(y / z));
	        
			//System.out.println(y + "/" + z + "=" + new DecimalFormat("00.00").format(y / z));
	        
	        
	        BigDecimal yy = BigDecimal.valueOf(y);
	        BigDecimal zz = BigDecimal.valueOf(z);
	        
	        System.out.println(yy + "/" + zz + "=" + yy.divide(zz, 3, BigDecimal.ROUND_UP) + " | " + yy.divide(zz, 3, BigDecimal.ROUND_UP).intValue());
	        
	        
		}
		
	}
	
}
